package com.imti.mall.product.mapper;

import com.imti.mall.model.pms.pojo.PmsProductCategoryAttributeRelation;
import com.imti.mall.model.pms.vo.PmsProductCategoryVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface PmsProductCategoryAttributeRelationMapper {


    /**
     * 查询商品分类和属性关系
     * @param productCategoryId
     * @return
     */
    List<PmsProductCategoryAttributeRelation> findPmsProductCategoryAttributeRelation(Integer productCategoryId);

    /**
     * 查询单条数据
     */
    @Select("select id,product_category_id,product_attribute_id  from pms_product_category_attribute_relation where product_category_id=#{id} and product_attribute_id=#{attrId}")
    PmsProductCategoryAttributeRelation getOnePmsProductCategoryAttributeRelation(Integer id, Integer attrId);

    /**
     * 修改分类属性关系
     */
    @Update("update pms_product_category_attribute_relation set product_attribute_id=#{attrId} where id=#{relationId}")
    int updatePmsProductCategoryAttributeRelation(Long relationId,Integer attrId);

    /**
     * 新增属性关系
     */
    @Insert("insert into pms_product_category_attribute_relation(product_attribute_id,product_attribute_id) values (#{id},#{attrId})")
    int insertPmsProductCategoryAttributeRelation(Integer id,Integer attrId);
}
